<?php
/**
 * #Celebrate Shieh
 *             ,%%%%%%%%,
 *           ,%%/\%%%%/\%%
 *          ,%%%\c "" J/%%%
 * %.       %%%%/ o  o \%%%
 * `%%.     %%%%    _  |%%%
 *  `%%     `%%%%(__Y__)%%'
 *  //       ;%%%%`\-/%%%'
 * ((       /  `%%%%%%%'
 *  \\    .'          |
 *   \\  /       \  | |
 *    \\/         ) | |
 *     \         /_ | |__
 *     (___________))))))) 攻城湿
 *
 *        _       _
 * __   _(_)_   _(_) __ _ _ __
 * \ \ / / \ \ / / |/ _` |'_ \
 *  \ V /| |\ V /| | (_| | | | |
 *   \_/ |_| \_/ |_|\__,_|_| |_|
 */

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    /**
     * 首页
     *
     * @param Request $request
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index( Request $request )
    {
        return $this->getHome()->SysInfoService($request);
    }

    /**
     * @param Request $request
     *发送邮件验证码
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function code( Request $request )
    {
        switch ( $request->input('id') ) {
            case '1':
                request()->offsetSet('status', 'a');
                break;
            case '2':
                request()->offsetSet('status', 'b');
                break;
            case '3':
                request()->offsetSet('status', 'b');
                break;
            case '4':
                request()->offsetSet('status', 'a');
                break;
            case '5':
                request()->offsetSet('status', 'a');
                break;
            case '6':
                request()->offsetSet('status', 'b');
                break;
            case '7':
                request()->offsetSet('status', 'c');
                break;
            case '8':
                request()->offsetSet('status', 'd');
                break;
            case '9':
                request()->offsetSet('status', 'b');
                break;
            default:
                return data(NULL, '未知错误', 1000);
                break;
        }
        return $this->getHome()->EmailCodeService($request);
    }

    /**
     *
     * 下载文件
     *
     * @param Request $request
     *
     * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
     */
    public function TextFile( Request $request )
    {
        return $this->getHome()->TextFileService($request);
    }

    /**
     * 获取省市区
     *
     * @param Request $request
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function region( Request $request )
    {
        return $this->getHome()->RegionCodeService($request);
    }

    /**
     * 获取邀请数据
     *
     * @param Request $request
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function user( Request $request )
    {
        return $this->getHome()->UserService($request);
    }

    /**
     * 清除缓存
     *
     * @param Request $request
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function cache( Request $request )
    {
        return $this->getHome()->CacheService($request);
    }
}
